<!-- 纵向布局 -->
<template>
  <el-container class="layout">
    <el-aside>
      <div class="aside-box" :style="{ width: isCollapse ? '65px' : '210px' }">
        <div class="logo flx-center">
          <img class="logo-img" src="@/assets/images/logo1.png" alt="logo" v-if="!isCollapse" />
          <img class="logo-img-mini" src="@/assets/images/logo1_mini.png" alt="logo1" v-else />
        </div>
        <el-scrollbar v-show="menuList && menuList.length > 0">
          <el-menu
            :default-active="activeMenu"
            :collapse="isCollapse"
            :router="false"
            :unique-opened="true"
            :collapse-transition="false"
          >
            <SubMenu :menuList="menuList" />
          </el-menu>
        </el-scrollbar>
      </div>
    </el-aside>
    <el-container>
      <el-header>
        <ToolBarLeft />
        <ToolBarRight />
      </el-header>
      <Main />
    </el-container>
  </el-container>
</template>

<script setup lang="ts" name="layoutVertical">
import { computed } from "vue";
import { useRoute } from "vue-router";

import { useGlobalStore } from "@/stores/modules/global";
import { hexToRgb } from "@/utils/color";
import Main from "@/layouts/components/Main/index.vue";
import ToolBarLeft from "@/layouts/components/Header/ToolBarLeft.vue";
import ToolBarRight from "@/layouts/components/Header/ToolBarRight.vue";
import SubMenu from "@/layouts/components/Menu/SubMenu.vue";
import { useMenuStore } from "@/stores/modules/menu";
import { getShowMenuList } from "@/utils";
const route = useRoute();

const globalStore = useGlobalStore();
const menuStore = useMenuStore();
const isCollapse = computed(() => globalStore.isCollapse);
const primary = computed((): number[] => hexToRgb(globalStore.primary));
const baseCol = computed((): string => `rgba(${primary.value[0]}, ${primary.value[1]}, ${primary.value[2]}, 1)`);
const menuList = computed(() => getShowMenuList(menuStore.subMenuList));
const activeMenu = computed(() => (route.meta.activeMenu ? route.meta.activeMenu : route.path) as string);
</script>

<style scoped lang="scss">
$base-col: v-bind("baseCol");
@import "./index.scss";
</style>
